package com.itbaizhan;

import java.util.Arrays;

//自定义一个简单的包装类（仅限于练习）
public class MyInteger02 {
    //定义属性，再初始化
    private final int value;
    //定义数组
    private static MyInteger02[] cache;
    private static int LOW =-128;
    private static int HIGH = 127;
    //构造器初始化
    public MyInteger02(int value) {
        this.value = value;
    }

    static {
        cache = new MyInteger02[HIGH-LOW+1];//256
        for(int i=LOW;i<=HIGH;i++){
            cache[i-LOW] = new MyInteger02(i);
        }
        System.out.println(Arrays.toString(cache));
    }

    @Override
    public String toString() {
        return value+"";
    }

    public static MyInteger02 value0f(int value){
        return new MyInteger02(value);
    }
    public int intValue(){
        return value;
    }
    public static void main(String[] args) {
        MyInteger02 a = new MyInteger02(20);
        MyInteger02 b = MyInteger02.value0f(30);
        int c = b.intValue();
    }
}
